package store.utils;

public class Pager {
    private int total;//总记录数
    private int pageSize = 5;//每页显示记录数
    private int currentPage;//当前页

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageCount() {
        return total % pageSize == 0 ? total / pageSize : total / pageSize + 1;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPrevious() {

        return currentPage == 1 ? 1 : currentPage - 1;
    }

    public int getNext() {
        return currentPage == getPageCount() ? currentPage : currentPage + 1;
    }

}
